Efficient object query processing technique on object&#39;s dynamic properties via pushdown

ABSTRACT

The present invention provides a method and system for a query on dynamic properties of objects. The method includes: obtaining a query; determining that the query pertains to at least one mapped dynamic property; obtaining mapping data for the at least one mapped dynamic property; and translating the query for the at least one mapped dynamic property according to the mapping data to run against a database. The method uses the stored mapping data of the dynamic property to translate the query on the mapped dynamic property such that it may be run against the database. In this manner, queries on mapped dynamic properties are performed through pushdown rather than in object space. This increases the efficiency of the queries.

FIELD OF THE INVENTION

[0001] The present invention relates to database networks, and more particularly to the execution of queries on objects in the database networks.

BACKGROUND OF THE INVENTION

[0002]FIG. 1 illustrates a conventional database network. The network comprises a plurality of clients 102, a network server 104, a Web Sphere™ server 106, and databases 108 containing objects. The WebSphere server 106 is an applications server, developed by International Business Machines, Corp.™, which functions as an extension to the network server 104. The WebSphere server 106 allows users to write object-oriented application programs and to design or install custom objects. These objects are stored as table structures in the database 108. The WebSphere server 106 is typically used with relational database systems, such as DB2™ or Oracle™.

[0003] As is well known in the art, the objects in the database 108 have class definitions. The class definitions contain information concerning static properties in the objects 108. Static properties is the attributes defined in the class definition. Each of the static properties are mapped to a table column in the database 108, and this mapping data is stored as metadata. The metadata takes the similar form of a Structured Query Language (SQL) view and the query translation processes are based on relational view rewrite. Some objects also have dynamic property capabilities. Dynamic properties on the contrary are not defined in the class definition. They are typically used for customizing an application without changing the class definition. They can be accessed using getPropertyBy and can be set using setPropertyBy methods that are defined in the class definition. By storing these data as dynamic properties, the user need not change the object's class definition each time a dynamic property is added or deleted. As with static properties, the dynamic properties may each be mapped to a table column in the database 108. Alternatively, one or more of them may by unmapped, and instead are stored in an overflow column.

[0004] Oftentimes, a user wishes to execute queries on the objects in the database 108. The WebSphere server 106 contains a query service 110 for this purpose. For static properties, the query refers to the attributes of the class definitions for the objects. Using metadata, the query system translates the query into a query against the database schema, and this is referred to as “pushdown”. If a query contains a method, instances of objects must be created and methods must be run on these instances, and this is referred to as running “in object space”. Because dynamic properties are accessed using the methods, evaluating the queries with dynamic properties is done in object space. Running queries in object space is usually slower than pushdown, and thus is inefficient.

[0005] Accordingly, there exists a need for a method for efficient object query on dynamic properties. The present invention addresses such a need.

SUMMARY OF THE INVENTION

[0006] The present invention provides a method and system for a query on dynamic properties of an object. The method includes: obtaining a query; determining that the query pertains to at least one mapped dynamic property; obtaining mapping data for the at least one mapped dynamic property; and translating the query for the at least one mapped dynamic property according to the mapping data to run against a database. The method uses the stored mapping data on the dynamic property to translate the query on the mapped dynamic property such that it may be run against the database. In this manner, queries on mapped dynamic properties are performed through pushdown rather than in object space. This increases the efficiency of the queries.

BRIEF DESCRIPTION OF THE FIGURES

[0007]FIG. 1 illustrates a conventional database network.

[0008]FIG. 2 is a flowchart illustrating a preferred embodiment of the method for an object query on dynamic properties in accordance with the present invention.

[0009]FIG. 3 is a flowchart illustrating in more detail the method for an object query on dynamic properties in accordance with the present invention.

DETAILED DESCRIPTION

[0010] The present invention provides a method for efficient object query on dynamic properties. The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. Various modifications to the preferred embodiment will be readily apparent to those skilled in the art and the generic principles herein may be applied to other embodiments. Thus, the present invention is not intended to be limited to the embodiment shown but is to be accorded the widest scope consistent with the principles and features described herein.

[0011] The method in accordance with the present invention performs the query on mapped dynamic properties of objects against the class definitions of the objects. The method uses the stored mapping data on the dynamic properties to translate the part of the query pertaining to the mapped dynamic properties such that they are run against the database. In this manner, queries on mapped dynamic properties are performed through pushdown rather than in object space. This increases the efficiency of the queries.

[0012] To more particularly describe the features of the present invention, please refer to FIGS. 2 and 3 in conjunction with the discussion below.

[0013]FIG. 2 is a flowchart illustrating a preferred embodiment of the method for an object query on dynamic properties in accordance with the present invention. First, the query is obtained, via step 202. The query service 110 then determines that at least part of the query pertains to at least one mapped dynamic property, via step 204. The mapping data for the at least one mapped dynamic property is then obtained, via step 206. This mapping data is used to translate the query to run against the database 108, via step 208. The query is then executed by the query service 110.

[0014] For example, consider the following employee class definition: class employee { public int P1; public int P2; public Object getPropertyBy(String name), public void setPropertyBy(String name, Object value); }

[0015] Assume that the employee class contains two static properties, P1 and P2, which are mapped to column 1 (C1) and column 2 (C2) of the database 108, respectively, of a table structure in the database 108. Assume that the employee class also contains three dynamic properties, A1, A2, and A3. A1 is mapped to column 3 (C3), and A2 is mapped to column 4 (C4). However, A3 is unmapped and thus is stored in the overflow column.

[0016] Assume that the following Object Oriented Structure Query Language (OOSQL) query has been obtained, via step 202:

[0017] Select e from eHome e

[0018] where

[0019] cast (e.getPropertyBy (“A1”) as double)>21,

[0020] This query is seeking the collection of objects, “e”, of the type employee from the collection of all employees in “eHome”, which satisfies the conditions which follow “where”. The cast operator is used in OOSQL when dealing with attributes or methods that return type object. Since the type of the value cannot be deduced from the class definition, the OOSQL cast operator must be used to specify this information in the query. Thus, the cast function is to convert the expression obtained by e.getPropertyBy (“A1”) into the “double” data type.

[0021] Since the query refers to A1, the query service 110 determines that it pertains to at least one mapped dynamic property, via step 204. Using the metadata:

[0022] create object view_view1 signature (int P1, int P2, double A1, double A2) as select q1.C1, q1.C2, q1.C3, q1.C4 from eTable q1;

[0023] the query service 110 obtains the mapping data for A1, i.e., that A1 is mapped to C3, via step 206. The query service 110 then translates the query so that the part pertaining to A1 is run against column C3 of the database 108, via step 208. In the preferred embodiment, the translation is performed by replacing the cast statement for A1 with column C3 of the database. The translated OOSQL query then reads:

[0024] Select make_object (q1.*) from eTable q1

[0025] where

[0026] C3>21,

[0027] The above OOSQL query is then translated into the database query:

[0028] select q1.*from eTable q1

[0029] where

[0030] C3>21.

[0031] This query is then executed. Since the translated query now refers to a column in the table, the query may be run against the table's class definition, and no methods are run on the instances of the objects. The make_object function which constructs object references is done by the query service 110. In this manner, the query which pertains to a mapped dynamic property is performed through pushdown, not in object space. This increases the efficiency of the query.

[0032]FIG. 3 is a flowchart illustrating in more detail the method for an object query on dynamic properties in accordance with the present invention. For illustrative purposes, assume that the following OOSQL query is obtained, via step 302: Select e from eHome e where cast (e.getPropertyBy (“A1”) as double) > 21 and P1 > 0 and cast (e.getPropertyBy(“A3”) as double) > 25;

[0033] First, the query service 110 determines whether the query pertains to static properties, via step 304. Since the query has the condition “P1>0”, P1 being a static property, the query service 110 then obtains the mapping data for P1, i.e., P1 is mapped to C1, via step 306. In the preferred embodiment, the translation is performed by replacing “P1” with its column, “C1”.

[0034] Next, the query service 110 determines whether the query pertains to mapped dynamic properties, via step 308. Since the query has the condition “cast (e.getPropertyBy (“A1”) as double)>21”, A1 being a mapped dynamic property, the query service 110 obtains the mapping data for A1, i.e., A1 is mapped to C3, via step 310, and translates the part of the query pertaining to A1 to run against the database 108, via step 312. In the preferred embodiment, the translation is performed by replacing A1 with column C3 of the database 108. Next, the query service 110 determines whether the query pertains to unmapped dynamic properties, via step 314. Since the query has the condition “cast (e.getPropertyBy (“A3”) as double)>25”, A3 being an unmapped dynamic property, the query service 110 has no mapping data for A3. The OOSQL query then reads: select make_object (q1. *) from eTable q1 where q1.C3 > 21 and q1.C1 > 0 and cast (make_object(q1. *).getPropertyBy(“A3”) as double) > 25;

[0035] The query service 110 then decomposes the OOSQL query into a database SQL query: select q1. *from eTable q1 where q1.C3 > 21 and q1.C1 > 0.

[0036] The query is then executed, via step 316. The make_object function which constructs object references, via step 318, and invocation of the getPropertyBy method for the unmapped dynamic property, via step 320, and converting the expression obtained by getPropertyBy (“A3”) into double data type, via step 322, is performed by the query service 110.

[0037] A method for an object query on dynamic properties has been disclosed. The method performs the query on mapped dynamic properties of objects against the database. The method uses the stored mapping data on the dynamic properties to translate the query on the mapped dynamic properties such that they may be run against the database. In this manner, queries on mapped dynamic properties are performed through pushdown rather than in object space. This increases the efficiency of the queries.

[0038] Although the present invention has been described in accordance with the embodiments shown, one of ordinary skill in the art will readily recognize that there could be variations to the embodiments and those variations would be within the spirit and scope of the present invention. Accordingly, many modifications may be made by one of ordinary skill in the art without departing from the spirit and scope of the appended claims. 

What is claimed is:
 1. A method for a query on dynamic properties of objects, comprising the steps of: (a) obtaining a query; (b) determining that the query pertains to at least one mapped dynamic property; (c) obtaining mapping data for the at least one mapped dynamic property; and (d) translating the query for the at least one mapped dynamic property according to the mapping data to run against a database.
 2. The method of claim 1, further comprising: (e) determining that the query pertains to at least one static property; and (f) translating the query for the at least one static property to run against the database.
 3. The method of claim 1, further comprising: (e) determining that the query pertains to at least one unmapped dynamic property; (f) executing the query; (g) creating the at least one of the plurality of objects; (h) executing a method for the at least one unmapped dynamic property on the at least one of the plurality of objects; and (i) converting a result of the executed method into a data type specified in the query.
 4. The method of claim 1, further comprising: (e) executing the translated query.
 5. The method of claim 4, wherein the translated query for the at least one mapped dynamic property is executed through pushdown.
 6. A computer readable medium with program instructions for providing an object query on dynamic properties, the instructions for: (a) obtaining a query; (b) determining that the query pertains to at least one mapped dynamic property; (c) obtaining mapping data for the at least one mapped dynamic property; and (d) translating the query for the at least one mapped dynamic property according to the mapping data to run against a database.
 7. The medium of claim 6, further comprising instructions for: (e) determining that the query pertains to at least one static property; and (f) translating the query for the at least one static property to run against the database.
 8. The medium of claim 6, further comprising instructions for: (e) determining that the query pertains to at least one unmapped dynamic property; (f) executing the query; (g) creating the at least one of the plurality of objects; (h) executing a method for the at least one unmapped dynamic property on the at least one of the plurality of objects; and (i) converting a result of the executed method into a data type specified by the query.
 9. The medium of claim 6, further comprising instructions for: (e) executing the translated query.
 10. The medium of claim 9, wherein the translated query for the at least one mapped dynamic property is executed through pushdown.
 11. A system, comprising: a database comprising a plurality of columns of a table, wherein at least one of the plurality of columns comprises at least one mapped dynamic property; and a server coupled to the database, wherein the server comprising a query service, wherein the query service provides a query on the at least one mapped dynamic property through pushdown.
 12. The system of claim 111, wherein performing the query further comprises the steps of: (a) obtaining the query; (b) determining that the query pertains to the at least one mapped dynamic property; (c) obtaining mapping data for the at least one mapped dynamic property; and (d) translating the query for the at least one mapped dynamic property according to the mapping data to run against the database.
 13. The system of claim 12, further comprising: (e) determining that the query pertains to at least one static property; and (f) translating the query for the at least one static property to run against the database.
 14. The system of claim 12, further comprising: (e) determining that the query pertains to at least one unmapped dynamic property; (f) executing the query; (g) creating the at least one of the plurality of objects; (h) executing a method for the at least one unmapped dynamic property on the at least one of the plurality of objects; and (i) converting a result of the executed method into a data type specified in the query.
 15. The system of claim 12, further comprising: (e) executing the translated query. 